package cn.ybk.system.service.impl;

import cn.ybk.basic.util.PageList;
import cn.ybk.system.domain.SystemType;
import cn.ybk.system.mapper.SystemTypeMapper;
import cn.ybk.system.query.SystemTypeQuery;
import cn.ybk.system.service.SystemTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SystemTypeServiceImpl implements SystemTypeService {

    @Autowired
    private SystemTypeMapper systemTypeMapper;

    @Override
    public List<SystemType> findAll() {
        return systemTypeMapper.findAll();
    }

    @Override
    public SystemType findById(Long id) {
        return systemTypeMapper.findById(id);
    }

    @Override
    public void add(SystemType systemType) {
        systemTypeMapper.add(systemType);

    }

    @Override
    public void update(SystemType systemType) {
        systemTypeMapper.update(systemType);

    }

    @Override
    public void delete(Long id) {
        systemTypeMapper.delete(id);
    }

    @Override
    public PageList<SystemType> queryByPage(SystemTypeQuery query) {
        Integer totals = systemTypeMapper.queryByCount(query);
        if (totals <= 0){
            return new PageList<>(0,new ArrayList<>());
        }
        final List<SystemType> rows = systemTypeMapper.queryByPage(query);

        return new PageList<>(totals,rows);
    }

    @Override
    public void batch(List<Long> ids) {
        systemTypeMapper.batch(ids);
    }


}
